export * from "../proto/weilapb_data_define";
import { WLBuildMsgRet, WLMsgHeader } from "../proto/weilapb_wrapper_data";

export interface WL_PromiseCallback {
    resolve: (value: any) => void;
    reject: (value: any) => void;
    data?: any;
}

export interface WL_LoginParam {
    retryCount: number;
    account: string;
    password: string;
    countryCode: string;
    isPasswordMd5: boolean;
    clientType: number;
    promiseCallback?: WL_PromiseCallback;
}

export enum WL_NetworkState {
    NET_CONNECTING_STATE,
    NET_CONNECTED_STATE,
    NET_DISCONNECTING_STATE,
    NET_DISCONNECTED_STATE
}

export enum WL_NetworkEventID {
    NET_EXCEPTION_IND_EVT,
    NET_CONNECT_EVT,
    NET_DISCONNECT_EVT,
    NET_SEND_DATA_EVT,
    NET_STATE_IND_EVT,
    NET_MSG_RECV_IND_EVT
}

export interface WL_NetworkEvent {
    eventId: WL_NetworkEventID;
    eventData: any;
}

export interface WL_RecvNetData {
    header?: WLMsgHeader;
    msgBinBuffer?: Uint8Array | null
}

export enum WL_CoreEventID {
    CORE_EVT_SEND_SERVICE_MESSAGE,
}

export interface WL_CoreEvent {
    eventId: number;
    eventData: any;
}

export interface WL_SendingMsgData {
    buildPbMsg: WLBuildMsgRet;
    timeout: number;
    promiseCallback?: WL_PromiseCallback;
}

export interface WeilaWorkerInterface {
    set_message_handler(handler: ((eventData: any) => void)|null): void;
    post_message(eventData: any): void;
}



export interface WeilaNetworkInterface {
    close(): void;
    send(data: Uint8Array): void;
    connect(url: string): void;
    disconnect(): void;
    onConnect(onConnect: () => void): void;
    onClose(onClose: () => void): void;
    onError(onError: (error: any) => void): void;
    onRecv(onRecv: (data: Uint8Array) => void): void;
}



export interface WeilaStorageInterface {
    getItem(key: string): any;
    setItem(key: string, value: string): void;
    removeItem(key: string): void;
}